<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 TRANSITIONAL//EN">
<html>
 <head>
  <title> new document </title>
  <meta name="generator" content="editplus">
  <meta name="author" content="">
  <meta name="keywords" content="">
  <meta name="description" content="">
  <script type="text/javascript">
	var XMLHttpRequestObject = false;
	var output='';
	var op='';
		
		if(window.XMLHttpRequest){
			XMLHttpRequestObject = new XMLHttpRequest();
		}else if(window.ActiveXObject){
			XMLHttpRequestObject = new ActiveXObject("Microsoft.XMLHTTP");
		}else{
			XMLHttpRequestObject = false;
		}

		function getData(src){
			if(XMLHttpRequestObject){
				XMLHttpRequestObject.open("GET",src);
				XMLHttpRequestObject.onreadystatechange = function (){
					if(XMLHttpRequestObject.readyState == 4 && XMLHttpRequestObject.status == 200 ){
						var gWeather = eval(XMLHttpRequestObject.responseXML);
						processData(gWeather);
					}
				}

				XMLHttpRequestObject.send(null);
			}
		}

		function processData(data){
			var root = data.documentElement;
			if(root.firstChild){
				var w = root.firstChild;
					
					if(w.childNodes.length > 0){
						for(i = 0; i<w.childNodes.length; i++){
							if(w.childNodes[i].childNodes.length > 0){
								op += "<br />" + i+ " " + w.childNodes[i].tagName + ": <br />";
								for(j=0;j<w.childNodes[i].childNodes.length;j++){
									var n = w.childNodes[i].childNodes[j].tagName ? w.childNodes[i].childNodes[j].tagName : 'text node';
									var d = w.childNodes[i].childNodes[j].getAttribute('data');
									op += "&nbsp;&nbsp;&nbsp;&nbsp;"+j + " " + n + ": " + d + "<br />";
								}
							}else{
									op += '<br />The node "'+ w.childNodes[i].tagName +'" has now ChildNodes!';
							}
						}
						output = op;
					}else{
						output = 'The xml file is null';
					}
			}
			document.body.innerHTML = '';
			document.body.innerHTML = output;
			var linkArr = document.getElementsByTagName('a');
				for(l = 0;l<linkArr.length;l++){
					linkArr[l].setAttribute('target','_blank');
				}
		}

		window.onload = function(){
			getData('http://www.google.com/ig/api?output=xml&hl=zh-cn&weather=beijing');
		}
  </script>
 </head>

 <body>
	Loading data......
 </body>
</html>
